package cn.hanna.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author smileha
 * @create 2021-10-16 14:48
 * @description
 */
@Configuration
public class ApplicationContextConfig {

    // 添加RestTemplate模板类到容器中
    @Bean
    @LoadBalanced  // 给RestTemplate添加负载均衡的能力，默认轮询的向指定应用名对应服务发送请求
    public RestTemplate addRestTemplate(){
        return new RestTemplate();
    }
}
